import functools
from flask import Flask, render_template, jsonify, redirect, request, url_for, session


def auth(func):
    @functools.wraps(func)
    def inner(*args, **kwargs):
        if session.get('username'):
            ret = func(*args, **kwargs)
            return ret
        print('-------------', url_for('user.login'))
        return redirect(url_for('user.login'))

    return inner
